Table of Contents

Class ExtensionMethodsString

Namespace
NDepend.Helpers
Assembly
NDepend.API.dll

Provides a set of extension methods dedicated to strings.

public static class ExtensionMethodsString
Inheritance
ExtensionMethodsString
Inherited Members

Methods (60)

Aggregate(IEnumerable<string>, string)

Aggregate string in this seq, with the string separator between each strings.

public static string Aggregate(this IEnumerable<string> seq, string separator)

Parameters

seq IEnumerable<string>

The sequence of strings to aggregate.

separator string

The separator string in between each string aggregated.

Returns

string

ContainsAll(string, string, string, string, string, string, StringComparison)

Gets a value indicating whether this string contains all of the strings specified.

public static bool ContainsAll(this string thisString, string str0, string str1, string str2, string str3, string str4, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the string that must be contained by thisString.

str1 string

One of the string that must be contained by thisString.

str2 string

One of the string that must be contained by thisString.

str3 string

One of the string that must be contained by thisString.

str4 string

One of the string that must be contained by thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

ContainsAll(string, string, string, string, string, StringComparison)

Gets a value indicating whether this string contains all of the strings specified.

public static bool ContainsAll(this string thisString, string str0, string str1, string str2, string str3, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the string that must be contained by thisString.

str1 string

One of the string that must be contained by thisString.

str2 string

One of the string that must be contained by thisString.

str3 string

One of the string that must be contained by thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

ContainsAll(string, string, string, string, StringComparison)

Gets a value indicating whether this string contains all of the strings specified.

public static bool ContainsAll(this string thisString, string str0, string str1, string str2, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the string that must be contained by thisString.

str1 string

One of the string that must be contained by thisString.

str2 string

One of the string that must be contained by thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

ContainsAll(string, string, string, StringComparison)

Gets a value indicating whether this string contains all of the strings specified.

public static bool ContainsAll(this string thisString, string str0, string str1, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the string that must be contained by thisString.

str1 string

One of the string that must be contained by thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

ContainsAll(string, string[], StringComparison)

Gets a value indicating whether this string contains all of the strings specified.

public static bool ContainsAll(this string thisString, string[] array, StringComparison stringComparison)

Parameters

thisString string

This string.

array string[]

An array containing strings that must be contained by thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

ContainsAny(string, string, string)

Gets a value indicating whether this string contains any case sensitive of the strings specified.

public static bool ContainsAny(this string thisString, string str0, string str1)

Parameters

thisString string

This string.

str0 string

One of the string that might be contained by thisString.

str1 string

One of the string that might be contained by thisString.

Returns

bool

ContainsAny(string, string, string, string)

Gets a value indicating whether this string contains any case sensitive of the strings specified.

public static bool ContainsAny(this string thisString, string str0, string str1, string str2)

Parameters

thisString string

This string.

str0 string

One of the string that might be contained by thisString.

str1 string

One of the string that might be contained by thisString.

str2 string

One of the string that might be contained by thisString.

Returns

bool

ContainsAny(string, string, string, string, string)

Gets a value indicating whether this string contains any case sensitive of the strings specified.

public static bool ContainsAny(this string thisString, string str0, string str1, string str2, string str3)

Parameters

thisString string

This string.

str0 string

One of the string that might be contained by thisString.

str1 string

One of the string that might be contained by thisString.

str2 string

One of the string that might be contained by thisString.

str3 string

One of the string that might be contained by thisString.

Returns

bool

ContainsAny(string, string, string, string, string, string)

Gets a value indicating whether this string contains any case sensitive of the strings specified.

public static bool ContainsAny(this string thisString, string str0, string str1, string str2, string str3, string str4)

Parameters

thisString string

This string.

str0 string

One of the string that might be contained by thisString.

str1 string

One of the string that might be contained by thisString.

str2 string

One of the string that might be contained by thisString.

str3 string

One of the string that might be contained by thisString.

str4 string

One of the string that might be contained by thisString.

Returns

bool

ContainsAny(string, string, string, string, string, string, StringComparison)

Gets a value indicating whether this string contains any of the strings specified.

public static bool ContainsAny(this string thisString, string str0, string str1, string str2, string str3, string str4, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the string that might be contained by thisString.

str1 string

One of the string that might be contained by thisString.

str2 string

One of the string that might be contained by thisString.

str3 string

One of the string that might be contained by thisString.

str4 string

One of the string that might be contained by thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

ContainsAny(string, string, string, string, string, string, params string[])

Gets a value indicating whether this string contains any case sensitive of the strings specified.

public static bool ContainsAny(this string thisString, string str0, string str1, string str2, string str3, string str4, params string[] array)

Parameters

thisString string

This string.

str0 string

One of the string that might be contained by thisString.

str1 string

One of the string that might be contained by thisString.

str2 string

One of the string that might be contained by thisString.

str3 string

One of the string that might be contained by thisString.

str4 string

One of the string that might be contained by thisString.

array string[]

An array of possible strings contained by thisString.

Returns

bool

Exceptions

NullReferenceException

null string reference in array not accepted.

ContainsAny(string, string, string, string, string, StringComparison)

Gets a value indicating whether this string contains any of the strings specified.

public static bool ContainsAny(this string thisString, string str0, string str1, string str2, string str3, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the string that might be contained by thisString.

str1 string

One of the string that might be contained by thisString.

str2 string

One of the string that might be contained by thisString.

str3 string

One of the string that might be contained by thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

ContainsAny(string, string, string, string, StringComparison)

Gets a value indicating whether this string contains any of the strings specified.

public static bool ContainsAny(this string thisString, string str0, string str1, string str2, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the string that might be contained by thisString.

str1 string

One of the string that might be contained by thisString.

str2 string

One of the string that might be contained by thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

ContainsAny(string, string, string, StringComparison)

Gets a value indicating whether this string contains any of the strings specified.

public static bool ContainsAny(this string thisString, string str0, string str1, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the string that might be contained by thisString.

str1 string

One of the string that might be contained by thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

ContainsAny(string, string[], StringComparison)

Gets a value indicating whether this string contains any of the strings specified.

public static bool ContainsAny(this string thisString, string[] array, StringComparison stringComparison)

Parameters

thisString string

This string.

array string[]

An array containing possible values for thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

ContainsIgnoreCase(string, string)

Gets a value indicating whether this string contains the string specified, the comparison being case insensitive.

public static bool ContainsIgnoreCase(this string container, string contained)

Parameters

container string

This string that might contain contained. If null, false is returned.

contained string

The string to seek in container. If null, false is returned. If empty, true is returned.

Returns

bool

true if contained occurs within container, else false.

Remarks

The comparison relies on OrdinalIgnoreCase.

EndsWithAny(string, string, string)

Gets a value indicating whether this string ends with case sensitive any of the strings specified.

public static bool EndsWithAny(this string thisString, string str0, string str1)

Parameters

thisString string

This string.

str0 string

One of the possible end string for thisString.

str1 string

One of the possible end string for thisString.

Returns

bool

EndsWithAny(string, string, string, string)

Gets a value indicating whether this string ends with case sensitive any of the strings specified.

public static bool EndsWithAny(this string thisString, string str0, string str1, string str2)

Parameters

thisString string

This string.

str0 string

One of the possible end string for thisString.

str1 string

One of the possible end string for thisString.

str2 string

One of the possible end string for thisString.

Returns

bool

EndsWithAny(string, string, string, string, string)

Gets a value indicating whether this string ends with case sensitive any of the strings specified.

public static bool EndsWithAny(this string thisString, string str0, string str1, string str2, string str3)

Parameters

thisString string

This string.

str0 string

One of the possible end string for thisString.

str1 string

One of the possible end string for thisString.

str2 string

One of the possible end string for thisString.

str3 string

One of the possible end string for thisString.

Returns

bool

EndsWithAny(string, string, string, string, string, string)

Gets a value indicating whether this string ends with case sensitive any of the strings specified.

public static bool EndsWithAny(this string thisString, string str0, string str1, string str2, string str3, string str4)

Parameters

thisString string

This string.

str0 string

One of the possible end string for thisString.

str1 string

One of the possible end string for thisString.

str2 string

One of the possible end string for thisString.

str3 string

One of the possible end string for thisString.

str4 string

One of the possible end string for thisString.

Returns

bool

EndsWithAny(string, string, string, string, string, string, string, string, string, StringComparison)

Gets a value indicating whether this string ends with any of the strings specified.

public static bool EndsWithAny(this string thisString, string str0, string str1, string str2, string str3, string str4, string str5, string str6, string str7, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the possible end string for thisString.

str1 string

One of the possible end string for thisString.

str2 string

One of the possible end string for thisString.

str3 string

One of the possible end string for thisString.

str4 string

One of the possible end string for thisString.

str5 string

One of the possible end string for thisString.

str6 string

One of the possible end string for thisString.

str7 string

One of the possible end string for thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

EndsWithAny(string, string, string, string, string, string, StringComparison)

Gets a value indicating whether this string ends with any of the strings specified.

public static bool EndsWithAny(this string thisString, string str0, string str1, string str2, string str3, string str4, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the possible end string for thisString.

str1 string

One of the possible end string for thisString.

str2 string

One of the possible end string for thisString.

str3 string

One of the possible end string for thisString.

str4 string

One of the possible end string for thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

EndsWithAny(string, string, string, string, string, string, params string[])

Gets a value indicating whether this string ends with case sensitive any of the strings specified.

public static bool EndsWithAny(this string thisString, string str0, string str1, string str2, string str3, string str4, params string[] array)

Parameters

thisString string

This string.

str0 string

One of the possible end string for thisString.

str1 string

One of the possible end string for thisString.

str2 string

One of the possible end string for thisString.

str3 string

One of the possible end string for thisString.

str4 string

One of the possible end string for thisString.

array string[]

An array containing possible end strings for thisString.

Returns

bool

Exceptions

NullReferenceException

null string reference in array not accepted.

EndsWithAny(string, string, string, string, string, StringComparison)

Gets a value indicating whether this string ends with any of the strings specified.

public static bool EndsWithAny(this string thisString, string str0, string str1, string str2, string str3, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the possible end string for thisString.

str1 string

One of the possible end string for thisString.

str2 string

One of the possible end string for thisString.

str3 string

One of the possible end string for thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

EndsWithAny(string, string, string, string, StringComparison)

Gets a value indicating whether this string ends with any of the strings specified.

public static bool EndsWithAny(this string thisString, string str0, string str1, string str2, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the possible end string for thisString.

str1 string

One of the possible end string for thisString.

str2 string

One of the possible end string for thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

EndsWithAny(string, string, string, StringComparison)

Gets a value indicating whether this string ends with any of the strings specified.

public static bool EndsWithAny(this string thisString, string str0, string str1, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the possible end string for thisString.

str1 string

One of the possible end string for thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

EndsWithAny(string, params string[])

Gets a value indicating whether this string ends with case sensitive any of the strings in array.

public static bool EndsWithAny(this string thisString, params string[] array)

Parameters

thisString string

This string.

array string[]

An array containing possible end strings for thisString.

Returns

bool

Exceptions

NullReferenceException

null string reference in array not accepted.

EndsWithAny(string, string[], StringComparison)

Gets a value indicating whether this string ends with any of the strings specified.

public static bool EndsWithAny(this string thisString, string[] array, StringComparison stringComparison)

Parameters

thisString string

This string.

array string[]

An array containing possible values for end of thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

EqualsAny(string, HashSet<string>)

Gets a value indicating whether hashset contains the string thisString.

public static bool EqualsAny(this string thisString, HashSet<string> hashset)

Parameters

thisString string

This string.

hashset HashSet<string>

An hashset containing possible values for this thisString.

Returns

bool

Remarks

This EqualsAny(string, string, string) overload can be used to check the value of thisString against a large number of strings, in a constant time.

EqualsAny(string, string, string)

Gets a value indicating whether this string is equal case sensitive to any of the strings specified.

public static bool EqualsAny(this string thisString, string str0, string str1)

Parameters

thisString string

This string.

str0 string

One of the possible value for thisString.

str1 string

One of the possible value for thisString.

Returns

bool

EqualsAny(string, string, string, string)

Gets a value indicating whether this string is equal case sensitive to any of the strings specified.

public static bool EqualsAny(this string thisString, string str0, string str1, string str2)

Parameters

thisString string

This string.

str0 string

One of the possible value for thisString.

str1 string

One of the possible value for thisString.

str2 string

One of the possible value for thisString.

Returns

bool

EqualsAny(string, string, string, string, string)

Gets a value indicating whether this string is equal case sensitive to any of the strings specified.

public static bool EqualsAny(this string thisString, string str0, string str1, string str2, string str3)

Parameters

thisString string

This string.

str0 string

One of the possible value for thisString.

str1 string

One of the possible value for thisString.

str2 string

One of the possible value for thisString.

str3 string

One of the possible value for thisString.

Returns

bool

EqualsAny(string, string, string, string, string, string)

Gets a value indicating whether this string is equal case sensitive to any of the strings specified.

public static bool EqualsAny(this string thisString, string str0, string str1, string str2, string str3, string str4)

Parameters

thisString string

This string.

str0 string

One of the possible value for thisString.

str1 string

One of the possible value for thisString.

str2 string

One of the possible value for thisString.

str3 string

One of the possible value for thisString.

str4 string

One of the possible value for thisString.

Returns

bool

EqualsAny(string, string, string, string, string, string, StringComparison)

Gets a value indicating whether this string is equal to any of the strings specified.

public static bool EqualsAny(this string thisString, string str0, string str1, string str2, string str3, string str4, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the possible value for thisString.

str1 string

One of the possible value for thisString.

str2 string

One of the possible value for thisString.

str3 string

One of the possible value for thisString.

str4 string

One of the possible value for thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

EqualsAny(string, string, string, string, string, string, params string[])

Gets a value indicating whether this string is equal case sensitive to any of the strings specified.

public static bool EqualsAny(this string thisString, string str0, string str1, string str2, string str3, string str4, params string[] array)

Parameters

thisString string

This string.

str0 string

One of the possible value for thisString.

str1 string

One of the possible value for thisString.

str2 string

One of the possible value for thisString.

str3 string

One of the possible value for thisString.

str4 string

One of the possible value for thisString.

array string[]

An array containing possible values for thisString.

Returns

bool

EqualsAny(string, string, string, string, string, StringComparison)

Gets a value indicating whether this string is equal to any of the strings specified.

public static bool EqualsAny(this string thisString, string str0, string str1, string str2, string str3, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the possible value for thisString.

str1 string

One of the possible value for thisString.

str2 string

One of the possible value for thisString.

str3 string

One of the possible value for thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

EqualsAny(string, string, string, string, StringComparison)

Gets a value indicating whether this string is equal to any of the strings specified.

public static bool EqualsAny(this string thisString, string str0, string str1, string str2, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the possible value for thisString.

str1 string

One of the possible value for thisString.

str2 string

One of the possible value for thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

EqualsAny(string, string, string, StringComparison)

Gets a value indicating whether this string is equal to any of the strings specified.

public static bool EqualsAny(this string thisString, string str0, string str1, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the possible value for thisString.

str1 string

One of the possible value for thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

EqualsAny(string, string[])

Gets a value indicating whether this string is equal case sensitive to any of the strings specified.

public static bool EqualsAny(this string thisString, string[] array)

Parameters

thisString string

This string.

array string[]

An array containing possible values for thisString.

Returns

bool

EqualsAny(string, string[], StringComparison)

Gets a value indicating whether this string is equal to any of the strings specified.

public static bool EqualsAny(this string thisString, string[] array, StringComparison stringComparison)

Parameters

thisString string

This string.

array string[]

An array containing possible values for thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

FirstCharToUpper(string)

Return word with first char as upper case.

public static string FirstCharToUpper(this string word)

Parameters

word string

The word to get first char as upper case.

Returns

string

Get4BytesHashCodeFast(string)

Get a 4 bytes string hash code, case-sensitive.

public static uint Get4BytesHashCodeFast(this string thisString)

Parameters

thisString string

The string to get hash code for.

Returns

uint

Remarks

This method is about 4 times more performant than StringComparer.OrdinalIgnoreCase.GetHashCode(str).
It processes characters two by two by using pointers.

Get8BytesHashCodeFast(string)

Get a 8 bytes string hash code, case-sensitive.

public static ulong Get8BytesHashCodeFast(this string thisString)

Parameters

thisString string

The string to get hash code for.

Returns

ulong

GetNullOrEmptyDescElseGetString(string)

If str is null, returns the string "null".
If str is empty, returns the string "empty".
Else return str.

public static string GetNullOrEmptyDescElseGetString(this string str)

Parameters

str string

The string reference.

Returns

string

GetWords(string)

Get the words in a code identifier.

public static string[] GetWords(this string identifier)

Parameters

identifier string

The code identifier

Returns

string[]

Remarks

Typically the identifier is the ICodeElement.SimpleName.
For a complete behavior description, see this method source code and tests here: https://stackoverflow.com/a/48185710/27194

IsNullOrEmpty(string)

Returns true if str is a null reference or an empty string.

public static bool IsNullOrEmpty(this string str)

Parameters

str string

The string reference.

Returns

bool

Remarks

An alternative to string.IsNullOrEmpty() with less characters.

StartsWithAny(string, string, string)

Gets a value indicating whether this string starts with case sensitive any of the strings specified.

public static bool StartsWithAny(this string thisString, string str0, string str1)

Parameters

thisString string

This string.

str0 string

One of the possible start string for thisString.

str1 string

One of the possible start string for thisString.

Returns

bool

StartsWithAny(string, string, string, string)

Gets a value indicating whether this string starts with case sensitive any of the strings specified.

public static bool StartsWithAny(this string thisString, string str0, string str1, string str2)

Parameters

thisString string

This string.

str0 string

One of the possible start string for thisString.

str1 string

One of the possible start string for thisString.

str2 string

One of the possible start string for thisString.

Returns

bool

StartsWithAny(string, string, string, string, string)

Gets a value indicating whether this string starts with case sensitive any of the strings specified.

public static bool StartsWithAny(this string thisString, string str0, string str1, string str2, string str3)

Parameters

thisString string

This string.

str0 string

One of the possible start string for thisString.

str1 string

One of the possible start string for thisString.

str2 string

One of the possible start string for thisString.

str3 string

One of the possible start string for thisString.

Returns

bool

StartsWithAny(string, string, string, string, string, string)

Gets a value indicating whether this string starts with case sensitive any of the strings specified.

public static bool StartsWithAny(this string thisString, string str0, string str1, string str2, string str3, string str4)

Parameters

thisString string

This string.

str0 string

One of the possible start string for thisString.

str1 string

One of the possible start string for thisString.

str2 string

One of the possible start string for thisString.

str3 string

One of the possible start string for thisString.

str4 string

One of the possible start string for thisString.

Returns

bool

StartsWithAny(string, string, string, string, string, string, StringComparison)

Gets a value indicating whether this string starts with any of the strings specified.

public static bool StartsWithAny(this string thisString, string str0, string str1, string str2, string str3, string str4, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the possible start string for thisString.

str1 string

One of the possible start string for thisString.

str2 string

One of the possible start string for thisString.

str3 string

One of the possible start string for thisString.

str4 string

One of the possible start string for thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

StartsWithAny(string, string, string, string, string, string, params string[])

Gets a value indicating whether this string starts with case sensitive any of the strings specified.

public static bool StartsWithAny(this string thisString, string str0, string str1, string str2, string str3, string str4, params string[] array)

Parameters

thisString string

This string.

str0 string

One of the possible start string for thisString.

str1 string

One of the possible start string for thisString.

str2 string

One of the possible start string for thisString.

str3 string

One of the possible start string for thisString.

str4 string

One of the possible start string for thisString.

array string[]

An array containing possible start strings for thisString.

Returns

bool

Exceptions

NullReferenceException

null string reference in array not accepted.

StartsWithAny(string, string, string, string, string, StringComparison)

Gets a value indicating whether this string starts with any of the strings specified.

public static bool StartsWithAny(this string thisString, string str0, string str1, string str2, string str3, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the possible start string for thisString.

str1 string

One of the possible start string for thisString.

str2 string

One of the possible start string for thisString.

str3 string

One of the possible start string for thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

StartsWithAny(string, string, string, string, StringComparison)

Gets a value indicating whether this string starts with any of the strings specified.

public static bool StartsWithAny(this string thisString, string str0, string str1, string str2, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the possible start string for thisString.

str1 string

One of the possible start string for thisString.

str2 string

One of the possible start string for thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

StartsWithAny(string, string, string, StringComparison)

Gets a value indicating whether this string starts with any of the strings specified.

public static bool StartsWithAny(this string thisString, string str0, string str1, StringComparison stringComparison)

Parameters

thisString string

This string.

str0 string

One of the possible start string for thisString.

str1 string

One of the possible start string for thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

StartsWithAny(string, params string[])

Gets a value indicating whether this string starts with case sensitive any of the strings in array.

public static bool StartsWithAny(this string thisString, params string[] array)

Parameters

thisString string

This string.

array string[]

An array containing possible start strings for thisString.

Returns

bool

Exceptions

NullReferenceException

null string reference in array not accepted.

StartsWithAny(string, string[], StringComparison)

Gets a value indicating whether this string starts with any of the strings specified.

public static bool StartsWithAny(this string thisString, string[] array, StringComparison stringComparison)

Parameters

thisString string

This string.

array string[]

An array containing possible values for start of thisString.

stringComparison StringComparison

One of the enumeration values that determines how this string is compared to value.

Returns

bool

ToCompressedBase64Url(string)

Compresses this string into a compact token made only of the characters A-Z a-z 0-9 - _: its UTF-8 bytes (no BOM) are compressed with Deflate, then encoded in base64url (RFC 4648 §5) without padding.

public static string ToCompressedBase64Url(this string thisString)

Parameters

thisString string

This string, can be empty.

Returns

string

The compressed base64url token, empty when this string is empty.

Remarks

The token needs no quoting or escaping on any command line, shell or operating system — quotes, line breaks and non-ASCII characters of this string included. Decode it with TryDecompressFromBase64Url(string, out string). The output is always encoded, even when it is longer than this string.

TryDecompressFromBase64Url(string, out string)

Decompresses a token produced by ToCompressedBase64Url(string) back into the original string.

public static bool TryDecompressFromBase64Url(this string thisString, out string decoded)

Parameters

thisString string

The compressed base64url token, can be empty.

decoded string

The original string, empty when the method returns false.

Returns

bool

true if this token has been decoded, else false.

Remarks

Never throws: a token holding a character outside A-Z a-z 0-9 - _, truncated, not Deflate-compressed or not decoding to valid UTF-8 makes the method return false.